import pprint

import pandas as pd

from src.core.indicators.standard_indicators import SmaIndicator
from src.data_access.data_handler import DataHandler
from src.data_access.timescale_repository import TimescaleRepository
from src.enums.timeframe import Timeframe

if __name__ == '__main__':
    # 显示所有列
    pd.set_option('display.max_columns', None)
    # 显示所有行
    # 设置value的显示长度为100，默认为50
    pd.set_option('max_colwidth', 100)

    db_url = "postgresql://postgres:postgres@127.0.0.1:15432/crypto?client_encoding=utf8"
    repository = TimescaleRepository(db_url)
    data_handler = DataHandler(repository)
    start_date = '2021-01-01 01:00:00'
    end_date = '2021-03-01 00:00:00'
    sma = SmaIndicator((Timeframe.TIMEFRAME_1H.value, 'close'), 20)
    data_frame = data_handler.prepare_data('ETHUSDT',
                                           [Timeframe.TIMEFRAME_1H, Timeframe.TIMEFRAME_5M],
                                           [sma],
                                           start_date,
                                           end_date)
    pprint.pprint(data_frame)
